package gameEngine.agents.teamMateModel;

import gameEngine.agents.Agent;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
/**
 * abstract class for all {@link TeamMateModel} change is only in initialization logic
 * @author alon
 *
 */
public abstract class InitTeamMateModel implements TeamMateModel {
	/**
	 * holds model as HashMap since most of the time ObservationAnalyzer will access an AgentMock
	 * to update its competence/epsilon Greedy
	 */
	HashMap<Integer,AgentMock> agents=new HashMap<Integer,AgentMock>();
	int myId;
	
	public InitTeamMateModel(int myId){
		this.myId=myId;
	}

	public void setMyId(int myId) {
		this.myId = myId;
	}

	public abstract void init(ArrayList<Agent> agents);
	
	public Collection<AgentMock> getTeamMates() {
		return agents.values();
	}

	
	public AgentMock getAgentById(int id) {
		return agents.get(id);
	}
	
	public AgentMock getSelf() {
		return getAgentById(myId);
	}
	
	public InitTeamMateModel clone(){
		if(this instanceof Iinit0Model){
			return new Iinit0Model(myId);
		}
		if(this instanceof Init0Model){
			return new Init0Model(myId);
		}
		if(this instanceof InitRandomModel){
			return new InitRandomModel(myId);
		}
		if(this instanceof InitTrueModel){
			return new InitTrueModel(myId);
		}
		return null;
	}

}
